<?php

require_once(sfConfig::get('sf_lib_dir').'/filter/base/BaseFormFilterPropel.class.php');

/**
 * Billing filter form base class.
 *
 * @package    utility
 * @subpackage filter
 * @author     Your name here
 */
class BaseBillingFormFilter extends BaseFormFilterPropel
{
  public function setup()
  {
    $this->setWidgets(array(
      'station_id'        => new sfWidgetFormPropelChoice(array('model' => 'Station', 'add_empty' => true)),
      'building_id'       => new sfWidgetFormPropelChoice(array('model' => 'Building', 'add_empty' => true)),
      'occupant_id'       => new sfWidgetFormPropelChoice(array('model' => 'Occupant', 'add_empty' => true)),
      'meter_no'          => new sfWidgetFormFilterInput(),
      'consumer_no'       => new sfWidgetFormFilterInput(),
      'billing_date'      => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate(), 'with_empty' => true)),
      'previous_reading'  => new sfWidgetFormFilterInput(),
      'present_reading'   => new sfWidgetFormFilterInput(),
      'units_consumed'    => new sfWidgetFormFilterInput(),
      'units_free'        => new sfWidgetFormFilterInput(),
      'units_total'       => new sfWidgetFormFilterInput(),
      'water_charges'     => new sfWidgetFormFilterInput(),
      'tv_charges'        => new sfWidgetFormFilterInput(),
      'split_charges'     => new sfWidgetFormFilterInput(),
      'window_charges'    => new sfWidgetFormFilterInput(),
      'gas_charges'       => new sfWidgetFormFilterInput(),
      'misc_charges'      => new sfWidgetFormFilterInput(),
      'furniture_charges' => new sfWidgetFormFilterInput(),
      'meter_rent'        => new sfWidgetFormFilterInput(),
      'grand_total'       => new sfWidgetFormFilterInput(),
      'print_status'      => new sfWidgetFormFilterInput(),
      'payment_status'    => new sfWidgetFormFilterInput(),
      'bill_type'         => new sfWidgetFormFilterInput(),
      'billing_category'  => new sfWidgetFormFilterInput(),
      'status'            => new sfWidgetFormFilterInput(),
      'created_at'        => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate(), 'with_empty' => true)),
      'updated_at'        => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate(), 'with_empty' => true)),
    ));

    $this->setValidators(array(
      'station_id'        => new sfValidatorPropelChoice(array('required' => false, 'model' => 'Station', 'column' => 'id')),
      'building_id'       => new sfValidatorPropelChoice(array('required' => false, 'model' => 'Building', 'column' => 'id')),
      'occupant_id'       => new sfValidatorPropelChoice(array('required' => false, 'model' => 'Occupant', 'column' => 'id')),
      'meter_no'          => new sfValidatorPass(array('required' => false)),
      'consumer_no'       => new sfValidatorPass(array('required' => false)),
      'billing_date'      => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDate(array('required' => false)), 'to_date' => new sfValidatorDate(array('required' => false)))),
      'previous_reading'  => new sfValidatorPass(array('required' => false)),
      'present_reading'   => new sfValidatorPass(array('required' => false)),
      'units_consumed'    => new sfValidatorPass(array('required' => false)),
      'units_free'        => new sfValidatorPass(array('required' => false)),
      'units_total'       => new sfValidatorPass(array('required' => false)),
      'water_charges'     => new sfValidatorPass(array('required' => false)),
      'tv_charges'        => new sfValidatorPass(array('required' => false)),
      'split_charges'     => new sfValidatorPass(array('required' => false)),
      'window_charges'    => new sfValidatorPass(array('required' => false)),
      'gas_charges'       => new sfValidatorPass(array('required' => false)),
      'misc_charges'      => new sfValidatorPass(array('required' => false)),
      'furniture_charges' => new sfValidatorPass(array('required' => false)),
      'meter_rent'        => new sfValidatorPass(array('required' => false)),
      'grand_total'       => new sfValidatorPass(array('required' => false)),
      'print_status'      => new sfValidatorPass(array('required' => false)),
      'payment_status'    => new sfValidatorPass(array('required' => false)),
      'bill_type'         => new sfValidatorPass(array('required' => false)),
      'billing_category'  => new sfValidatorPass(array('required' => false)),
      'status'            => new sfValidatorPass(array('required' => false)),
      'created_at'        => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDate(array('required' => false)), 'to_date' => new sfValidatorDate(array('required' => false)))),
      'updated_at'        => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDate(array('required' => false)), 'to_date' => new sfValidatorDate(array('required' => false)))),
    ));

    $this->widgetSchema->setNameFormat('billing_filters[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    parent::setup();
  }

  public function getModelName()
  {
    return 'Billing';
  }

  public function getFields()
  {
    return array(
      'id'                => 'Number',
      'station_id'        => 'ForeignKey',
      'building_id'       => 'ForeignKey',
      'occupant_id'       => 'ForeignKey',
      'meter_no'          => 'Text',
      'consumer_no'       => 'Text',
      'billing_date'      => 'Date',
      'previous_reading'  => 'Text',
      'present_reading'   => 'Text',
      'units_consumed'    => 'Text',
      'units_free'        => 'Text',
      'units_total'       => 'Text',
      'water_charges'     => 'Text',
      'tv_charges'        => 'Text',
      'split_charges'     => 'Text',
      'window_charges'    => 'Text',
      'gas_charges'       => 'Text',
      'misc_charges'      => 'Text',
      'furniture_charges' => 'Text',
      'meter_rent'        => 'Text',
      'grand_total'       => 'Text',
      'print_status'      => 'Text',
      'payment_status'    => 'Text',
      'bill_type'         => 'Text',
      'billing_category'  => 'Text',
      'status'            => 'Text',
      'created_at'        => 'Date',
      'updated_at'        => 'Date',
    );
  }
}
